package cn.schoolwow.util.test.module.query.instanceList.flow.query;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.domain.query.instanceList.QueryInstanceList;
import cn.schoolwow.util.test.module.common.domain.User;
import org.junit.Assert;

import java.util.List;

public class InstanceQueryGetOneFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        List<User> userList = (List<User>) flowContext.checkData("userList");

        for(User user:userList){
            User queryUser = QueryInstanceList.newQuery(userList)
                    .addQuery("username", user.username)
                    .addQuery("password", user.password)
                    .execute()
                    .checkOne();
            Assert.assertEquals(user, queryUser);
        }
    }

    @Override
    public String name() {
        return "用户单个实例查询";
    }
}
